<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@page import="domain.Project"%>
<%@page import="java.util.List"%>
<%
	List<Project> projects = (ArrayList<Project>) request.getAttribute("projects");
	String message = (String) request.getAttribute("message");
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Project List</title>
<link href="./resources/style/mainStyle.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
	window.onload = function(){
		if("<%=message%>" != "null" ){
			alert("<%=message%>");
		}
	}

	function submitForm(id){
		document.getElementById("projectId").value = id;
		document.forms["projectSelectionForm"].submit();
	}
	
</script>

</head>
<body>
	<br/>
	<div align="center">
		<div class='box' style="width: 60%" align="center">
			<div class='boxtop'><div></div></div>
		  		<div class='boxcontent'>
		  			<form action="./project" id="projectSelectionForm" method="get">
						<input type="hidden" name="projectId" id="projectId" value="" />
		   			</form>
	   				<i>Please select the project you want to open!!</i>
		   			<ul>
		   			<%
		   				for(int i=0; projects!=null && i<projects.size(); i++){
		   					Project project = projects.get(i);
		   			%>
		   				<li>
		   					<a href="javascript:submitForm('<%=project.getId() %>')"><%=project.getName() %></a>
		   				</li>
		   			<% }%>
		   			</ul>
		  		</div>
		 	<div class='boxbottom'><div></div></div>
		</div>
	</div>
	
	<br/>
	<div align="center">
		<div class='box' style="width: 60%" align="center">
			<div class='boxtop'><div></div></div>
		  		<div class='boxcontent'>
		  			<form action="./participant" method="post">
		  				<select name="projectId" id="projectId">
							<option value="">--Select Project--</option>
							<%
								for( int i=0; projects!=null && i<projects.size(); i++){
									Project project = (Project)projects.get(i);
									if(!project.isDuplication()){
							%>
								<option value="<%=project.getId() %>"><%=project.getName() %></option>
								<%} %>
							<%} %>
						</select>
						<input class="button " type="submit" value="Duplicate Project" />
		   			</form>
		  		</div>
		 	<div class='boxbottom'><div></div></div>
		</div>
	</div>
	<br/>
	
	<div align="center">
		<div class='box' style="width: 60%" align="center">
			<div class='boxtop'><div></div></div>
		  		<div class='boxcontent'>
		  			<form action="./resultCombination" method="get">
		  				<select name="projectId" id="projectId">
							<%
								for( int i=0; projects!=null && i<projects.size(); i++){
									Project project = (Project)projects.get(i);
									if(!project.isDuplication()){
							%>
								<option value="<%=project.getId() %>"><%=project.getName() %></option>
								<%} %>
							<%} %>
						</select>
						<input class="button " type="submit" value="Combine Result" />
		   			</form>
		  		</div>
		 	<div class='boxbottom'><div></div></div>
		</div>
	</div>
	<br/>
</body>
</html>